using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model;
using ZR.Model.System;
using ZR.Model.System.Dto;
using ZR.ServiceCore.Services.IService;

namespace ZR.Admin.WebApi.Controllers.System
{
    /// <summary>
    /// 报警记录管理
    /// </summary>
    [Verify]
    [Route("system/alarmRecord")]
    [ApiExplorerSettings(GroupName = "sys")]
    public class AlarmRecordController : BaseController
    {
        /// <summary>
        /// 报警记录服务
        /// </summary>
        private readonly IAlarmRecordService _alarmRecordService;

        public AlarmRecordController(IAlarmRecordService alarmRecordService)
        {
            _alarmRecordService = alarmRecordService;
        }

        /// <summary>
        /// 查询报警记录列表
        /// </summary>
        /// <param name="request">查询参数</param>
        /// <returns></returns>
        [HttpPost("list")]
        public IActionResult List([FromBody] AlarmRecordListRequest request)
        {
            var query = new AlarmRecordQueryDto
            {
                Id = request.Id,
                SourceTable = request.SourceTable,
                XCoordinate = request.XCoordinate,
                YCoordinate = request.YCoordinate,
                WindSpeed = request.WindSpeed,
                WindDirection = request.WindDirection,
                BeginTime = request.BeginTime,
                EndTime = request.EndTime,
                TimeParam = request.TimeParam,
                Max = request.Max,
                Min = request.Min,
                // 传递新的查询参数
                WindSpeedLike = request.WindSpeedLike,
                XCoordinateMin = request.XCoordinateMin,
                XCoordinateMax = request.XCoordinateMax,
                YCoordinateMin = request.YCoordinateMin,
                YCoordinateMax = request.YCoordinateMax
            };
            var pager = new PagerInfo
            {
                PageNum = request.PageNum,
                PageSize = request.PageSize
            };
            var list = _alarmRecordService.SelectAlarmRecordList(query, pager);
            return SUCCESS(list);
        }
    }
}

